package cc.wanforme.fsync.config.restUpload;

import cc.wanforme.st.server.util.FileUtil;

public class SimpleProgressTracker implements FileUploadProgressTracker{
    private int progress = 0;  // 0-100
    private long sizeSend = 0; // 已发送
    private long sizeTotal = 0; // 总大小

    private String sizeSendStr = "";
    private String sizeTotalStr = "";

    public SimpleProgressTracker(long sizeTotal) {
        this.sizeTotal = sizeTotal;
        this.sizeTotalStr = FileUtil.readableFileSize(sizeTotal);
    }

    public void trackProgress(int progress, long sizeSend){
        this.progress = progress;
        this.sizeSend = sizeSend;
        this.sizeSendStr = FileUtil.readableFileSize(sizeSend);
//        System.out.println(">>>>" + progress + "," + FileUtil.readableFileSize(sizeSend));
    }

    public void finished() {
        this.progress = 100;
    }

    public int getProgress() {
        return progress;
    }

    public void setProgress(int progress) {
        this.progress = progress;
    }

    public long getSizeSend() {
        return sizeSend;
    }

    public void setSizeSend(long sizeSend) {
        this.sizeSend = sizeSend;
    }

    public long getSizeTotal() {
        return sizeTotal;
    }

    public void setSizeTotal(long sizeTotal) {
        this.sizeTotal = sizeTotal;
    }

    public String getSizeSendStr() {
        return sizeSendStr;
    }

    public void setSizeSendStr(String sizeSendStr) {
        this.sizeSendStr = sizeSendStr;
    }

    public String getSizeTotalStr() {
        return sizeTotalStr;
    }

    public void setSizeTotalStr(String sizeTotalStr) {
        this.sizeTotalStr = sizeTotalStr;
    }
}